import { NativeModules } from 'react-native';
import { isIOS } from '../../constant';

const registerAudioFrameObserver = (engineHandle: number): void => {
  if (isIOS) return;
  if (NativeModules.AgoraRawdata.registerAudioFrameObserver) {
    NativeModules.AgoraRawdata.registerAudioFrameObserver(engineHandle);
  }
};

const registerVideoFrameObserver = (engineHandle: number): void => {
  if (isIOS) return;
  if (NativeModules.AgoraRawdata.registerVideoFrameObserver) {
    NativeModules.AgoraRawdata.registerVideoFrameObserver(engineHandle);
  }
};

const unregisterAudioFrameObserver = (): void => {
  if (isIOS) return;
  if (NativeModules.AgoraRawdata.unregisterAudioFrameObserver) {
    NativeModules.AgoraRawdata.unregisterAudioFrameObserver();
  }
};

const unregisterVideoFrameObserver = (): void => {
  if (isIOS) return;
  if (NativeModules.AgoraRawdata.unregisterVideoFrameObserver) {
    NativeModules.AgoraRawdata.unregisterVideoFrameObserver();
  }
};

export default {
  registerAudioFrameObserver,
  registerVideoFrameObserver,
  unregisterAudioFrameObserver,
  unregisterVideoFrameObserver
};
